package framebl;

import java.rmi.RemoteException;
import java.util.ArrayList;

import dataFactory.DataFactory;
import frameDataService.FrameDataService;
import message.Message;
import PO.FramePO;
import VO.FrameVO;

public class Frame {
	
	public Message inputFrame(FrameVO frameVO) throws RemoteException {
		//
		DataFactory factory=new DataFactory();
		FrameDataService fds=factory.getFrameDataService();
		//
		FramePO framePO=new FramePO(frameVO.getDepartment(),frameVO.getModule(),frameVO.getCourseType(),
				frameVO.getSN(),frameVO.getCategory(),frameVO.getCourseName(),frameVO.getCredit(),
				frameVO.getTime());
		return fds.add(framePO);
		
	}
	
	public Message modifyFrame(FrameVO frameVO) throws RemoteException {
		//
		DataFactory factory=new DataFactory();
		FrameDataService fds=factory.getFrameDataService();
		//
		FramePO framePO=new FramePO(frameVO.getDepartment(),frameVO.getModule(),frameVO.getCourseType(),
				frameVO.getSN(),frameVO.getCategory(),frameVO.getCourseName(),frameVO.getCredit(),
				frameVO.getTime());
		return fds.update(framePO);
	}
	
	public ArrayList<FrameVO> showFrame(String dp) throws RemoteException {
		//
		DataFactory factory=new DataFactory();
		FrameDataService fds=factory.getFrameDataService();
		//
		ArrayList<FramePO> poList=fds.find(dp);
		ArrayList<FrameVO> voList=new ArrayList<FrameVO>();
		for(int i=0;i<poList.size();i++){
			FramePO po=poList.get(i);
			FrameVO vo=new FrameVO(po.getDepartment(),po.getModule(),po.getCourseType(),po.getSN(),
					po.getCategory(),po.getCourseName(),po.getCredit(),po.getTime());
			voList.add(vo);
		}
		return voList;
	}


}
